import request from './request'

// 部门数据类型
export interface DepartmentData {
  id: number
  name: string
  code: string
  manager: string
  phone: string
  employeeCount: number
  createTime: string
  parentId?: number
  children?: DepartmentData[]
}

// 获取部门列表
export const getDepartmentList = () => {
  return request({
    url: '/departments/list',
    method: 'post',
    data: {
    }
  })
}

// 新增部门
export const addDepartment = (department: Omit<DepartmentData, 'id' | 'createTime' | 'children'>) => {
  return request({
    url: '/departments/add',
    method: 'post',
    data: department
  })
}

// 编辑部门
export const updateDepartment = (department: DepartmentData) => {
  return request({
    url: '/departments/update',
    method: 'post',
    data: department
  })
}

// 删除部门
export const deleteDepartment = (id: number) => {
  return request({
    url: '/departments/delete',
    method: 'post',
    data: { id }
  })
}

// kpiIds
export const getDepartmentKPIIds = (id: number) => {
  return request({
    url: '/departments/kpiIds',
    method: 'post',
    data: { id }
  })
}
